﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SwenAssignment3.Classes;

namespace SwenAssignment3.HousekeepingManagementModule
{
    public partial class StaffCreation : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void btnCancel_Click(object sender, ImageClickEventArgs e)
        {

        }

        protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
        {
            string staffid = tbxStaffID.Text;
            string firstname = tbxfirstName.Text;
            string lastname = tbxlastName.Text;
            DateTime dob = Convert.ToDateTime(tbxDOB.Text);
            string address = tbxAddress.Text;
            int phonenumber = Convert.ToInt32(tbxPhone.Text);
            string banknumber = tbxbankAccount.Text;
            string dutyid = ddldutyID.Text;

            StaffProfile newStaff = new StaffProfile(staffid, firstname, lastname, dob, address, phonenumber, banknumber, dutyid);

            bool n = DRHotelDBManager.searchUserByStaffID(newStaff.StaffID);

            if (n == true)
            {
                lblStatus.Text = "Staff ID already been used";
            }
            else
            {
                int result = DRHotelDBManager.createNewStaff(newStaff);
                if (result == 1)
                {
                    Server.Transfer("~/HousekeepingManagementModule/StaffManagement.aspx");
                }
            }
        }
    }
}